<?php

class PackageController extends BaseController
{

	/**
	 * 满就送活动管理
	 */
	public function actionAdmin()
	{
		$model=new ProPackage('search');
		$model->unsetAttributes();  // clear any default values
		$model->zpp_id = array(1,2);//不为删除

		if(isset($_GET['ProPackage']))
			$model->attributes=$_GET['ProPackage'];
		
		$this->render('admin',array(
				'model'=>$model,
		));
	}
	
	/**
	 * 单条批量删除满就送活动
	 */
	public function actionDelete(){
		//操作ID号格式处理
		if(isset($_GET['id'])){
			$id = $_GET['id'];
		}elseif(isset($_POST['ids'])){
			$id =$_POST['ids'];
		}else{
			throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
		}
		$id = is_array($id)?join(',',$id):(int)$id;
		//处理条件
		$criteria=new CDbCriteria;
		$criteria->addCondition("zpp_id in ($id)");
		//修改内容
		$set = array('zpp_status'=>'3');
		//执行操作
		if(ProPackage::model()->updateAll($set,$criteria)){
			//成功跳转
			$this->redirect(Yii::app()->request->urlReferrer);
		}
	}

}